axios.defaults.baseURL = '../login/';
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.transformRequest =function (data) {
    let transObj='';
    for(let i in data){
        transObj+=i+'='+data[i]+'&';
    }
    return transObj;
}

const vm = new Vue({
    el:'#dv',
    data:{
        username:'',
        userpassword:'',
        autosign:0,
    },
    methods:{
        sign(){
            axios.post('loginX.php',
                {name: this.username,
                 password: this.userpassword,
                 auto: this.autosign})
                .then(result => {
                    if (result.status === 200) {
                        if(result.data.code==200){
                            Cookies.set('name', this.username, { expires: 7, path: '/' });
                            location.href='student.html'
                        }
                    } else {
                        alert(result.data.msg)
                    }
                })
        }
    },
    beforeCreat(){

    },
    created(){

    }
})

